/*************************************************************************
 > File Name: monolith/interface/inference/ultra_face_dect_model.h
 > Author: dzhang
 > Mail: dong.zhang@ingenic.com
 > Created Time : Sun 17 Jan 2021 10:11:07 PM CST
 > Description:
 ************************************************************************/

#ifndef _MONOLITH_INTERFACE_INFERENCE_ULTRA_FACE_DECT_MODEL_H
#define _MONOLITH_INTERFACE_INFERENCE_ULTRA_FACE_DECT_MODEL_H
#pragma once
#include "monolith/core/macros.h"
#include "monolith/interface/inference/common.h"
#include "monolith/interface/inference/model.h"
CC_NAME_SPACE_BEGIN
namespace inference {

class UltraFaceDectModel: public Model {
public:
    static UltraFaceDectModel* get_instatnce();

    static int init(ModelParameter model_parameter, float score_threshold =
            0.7, float iou_threshold = 0.3, int topk = -1);

    int run(uint8_t* data, std::vector<Box> &face_list, int input_width,
            int input_height, int input_channel);

protected:
    void generateBBox(std::vector<Box> &bbox_collection, MNN::Tensor *scores,
            MNN::Tensor *boxes, int input_width, int input_height);

    UltraFaceDectModel(ModelParameter model_parameter, float score_threshold =
            0.7, float iou_threshold = 0.3, int topk = -1);

private:
    static UltraFaceDectModel* model_;

private:
    int num_anchors_;
    int num_featuremap_ = 4;
    float score_threshold_;
    float iou_threshold_;
    const float center_variance_ = 0.1;
    const float size_variance_ = 0.2;
    const std::vector<std::vector<float>> min_boxes_ = {
            { 10.0f, 16.0f, 24.0f }, { 32.0f, 48.0f }, { 64.0f, 96.0f }, {
                    128.0f, 192.0f, 256.0f } };
    const std::vector<float> strides_ = { 8.0, 16.0, 32.0, 64.0 };
    std::vector<std::vector<float>> featuremap_size_;
    std::vector<std::vector<float>> shrinkage_size_;
    std::vector<int> w_h_list_;
    std::vector<std::vector<float>> priors_ = { };

};

} // namespace inference
CC_NAME_SPACE_END

#endif //MONOLITH_INTERFACE_INFERENCE_ULTRA_FACE_DECT_MODEL_H
